<?template name="game/main"?>
<link rel="stylesheet" href="/s/game/main.css{{if v}}${v}{{/if}}" type="text/css">
<script src="/j/game/game.js{{if v}}${v}{{/if}}"></script>
<script src="/j/game/reference.js{{if v}}${v}{{/if}}"></script>
<script src="/j/game/menu.js{{if v}}${v}{{/if}}"></script>
<script src="/j/game/leader_list.js{{if v}}${v}{{/if}}"></script>
<script src="/j/game/command.js{{if v}}${v}{{/if}}"></script>
<script src="/j/game/army.js{{if v}}${v}{{/if}}"></script>
<script src="/j/game/personal.js{{if v}}${v}{{/if}}"></script>
<script src="/j/game/inventory.js{{if v}}${v}{{/if}}"></script>
<script src="/j/game/task.js{{if v}}${v}{{/if}}"></script>
<script>
mc.game.wait_load = function(){
	if(!mc.game.tryed){
		mc.game.tryed = 1;
	}
	if(true
	   && mc.game.init
	   && mc.game.menu
	   && mc.game.load_proto
	   && mc.game.leader_list
	   && mc.game.chat_setting
	   && mc.game.army
	   && mc.game.personal
	   && mc.game.inventory
	   && mc.game.task
	){
		mc.game.init(mc.game.tryed);
	}else{
		mc.game.tryed++;
		window.setTimeout(mc.game.wait_load,50);
	}
}
</script>
<?/template?>

<?template name="game/main-menu"?>
<div id="menu_title">
	&nbsp;
</div>
<div id="menu_panel" style="position:absolute">
	{{each menu}}
		<div class="menu-item">
			<a href="mc.game.menu.select?{{= $index}}"
			   command="{{= $value.command}}"
			   class="mc"{{if $value.selectable}} selectable="1"{{/if}}
			   title="{{= $value.tooltip}}">{{html $value.title}}</a>
		</div>
	{{/each}}
</div>
<div id="menu_context">
</div>
<?/template?>


<?template name="menu_context"?>
<div>
	<div>
		<img class="leader-bx" src='${window.path_to_img}leaders/${p.img2}'>
	</div>
	<div>
		${p.title}
	</div>
	<div>
		{{html p.desc}}
	</div>
</div>
<?/template?>


<?template name="leader_list"?>
<div class="scrolled" id="leader_list">
	<div>
		{{each list}}
		<div class="leader" style="float: left" entry="${$value.e}" ct="${$value.ct}">
			<img class="leader" src='${window.path_to_img}leaders/${$value.p.img}'>
		</div>
		{{/each}}
	</div>
</div>
<div></div>
<div></div>
<?/template?>

<?template name="army_unit_list"?>
<div class="scrolled" id="unit_list">
	<div>
	{{each list}}
		<div class="unit" style="float: left" entry="${$value.e}">
			<img class="unit" src='${window.path_to_img}units/${$value.p.img}'/>
			<div class="unit-count"><span>${$value.c}</span></div>
		</div>
	{{/each}}
	</div>
</div>
<?/template?>

<?template name="army_item_list"?>
<div class="scrolled" id="item_list">
	<div>
	{{each list}}
		<div class="item" style="float: left" entry="${$value.e}">
			<img class="item" src='${window.path_to_img}items/${$value.p.img}'>
		</div>
	{{/each}}
	</div>
</div>
<?/template?>

<?template name="personal_unit_list"?>
<div class="scrolled" id="unit_list">
	<div>
	{{each list}}
		<div class="unit" style="float: left">
			<div>
				{{if $value.count > 0}}
				<span><a class="mc"
					href="mc.game.personal.tosource?${$data.source};${$data.target};${proto.entry}"
				><img src="/i/minus1.png"></a></span>
				{{/if}}

				<span>${$value.count}</span>

				{{if $value.source > 0}}
				<span><a class="mc"
					href="mc.game.personal.toleader?${$data.source};${$data.target};${proto.entry}"
				><img src="/i/plus1.png"></a></span>
				{{/if}}
			</div>
			<img class="unit" src='${window.path_to_img}units/${proto.img}'/>
			<div><span>${$value.source}</span>
			</div>
		</div>
	{{/each}}
	</div>
</div>
<?/template?>

<?template name="personal_unit_source"?>
<div class="scrolled" id="unit_list">
	<div>
	{{each list}}
		<div class="unit" style="float: left">
			<div><span>${$value.count}</span>
				<span><a class="mc"
					href="mc.game.personal.addsource?${$data.target};${proto.entry}"
				><img src="/i/plus1.png"></a></span>
			</div>
			<img class="unit" src='${window.path_to_img}units/${proto.img}'/>
		</div>
	{{/each}}
	</div>
</div>
<?/template?>

<?template name="inventory_item_has"?>
<div class="scrolled" id="item_list_has">
	<div>
	{{each has}}
		<div class="item" style="float: left">
			<img class="item" src='${window.path_to_img}items/${proto.img}'/>
			<div>
				<span><a class="mc"
					href="mc.game.inventory.tosource?${$data.source};${$data.target};${$value.entry}"
				><img src="/i/minus1.png"></a></span>
			</div>
		</div>
	{{/each}}
	</div>
</div>
<?/template?>

<?template name="inventory_item_can"?>
<div class="scrolled" id="item_list_can">
	<div>
	{{each can}}
		<div class="item" style="float: left">
			<div>
				<span><a class="mc"
					href="mc.game.inventory.toleader?${$data.source};${$data.target};${$value.entry}"
				><img src="/i/plus1.png"></a></span>
			</div>
			<img class="item" src='${window.path_to_img}items/${proto.img}'/>
		</div>
	{{/each}}
	</div>
</div>
<?/template?>


<?template name="inventory_item_source_has"?>
<div class="scrolled" id="item_list">
	<div>
	{{each has}}
		<div class="item" style="float: left">
			<div>
				<span><a class="mc"
					href="mc.game.inventory.addsource?${$data.target};${proto.entry}"
				><img src="/i/plus1.png"></a></span>
			</div>
			<img class="item" src='${window.path_to_img}items/${proto.img}'/>
		</div>
	{{/each}}
	</div>
</div>
<?/template?>
